package com.jiahui.vote.controller;

import com.jiahui.vote.entity.Vote;
import com.jiahui.vote.service.VoteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class MainController {
    @Autowired
    VoteService voteService;
    @GetMapping
    public String index(){
        return "login";
    }
    @GetMapping("/")
    public String index01(){
        return "login";
    }
    @GetMapping("/list")
    public String list(Model model){
        Vote[] votes=voteService.getAllVotes();
        model.addAttribute("votes",votes);
        return "index";
    }
}
